#include <iostream>
#include <string>
using namespace std;
//TODO:
typedef long long ll;

const int N = 55;
int n, sum;
bool a[N], b[N][N];
inline ll pow(ll base, ll index) {
	ll res = 1;
	while (index) {
		if (index & 1) res = res * base;
		base = base * base;
		index >>= 1;
	}
	return res;
}
int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
	freopen("testdata.in", "r", stdin);
	freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
	freopen("gamma.in", "r", stdin);
	freopen("gamma.out", "w", stdout);
#endif
#endif
	std::string str;
	cin >> n;
	cin >> str;
	for (int i = 0; i < n; ++i) {
		if (str[i] == '?') sum++;
	}
	for (int i = 0; i < n; ++i) {
		cin >> str;
		for (int j = 0; j < n; ++j) {
			b[i][j] = (str[j] == 'N' ? false : true);
		}
	}
	printf("%lld", pow(2, sum) - 1);
	return 0;
}